package com.ruoyi.edge.application.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.application.domain.ServiceManagement;
import com.ruoyi.edge.application.mapper.ServiceManagementMapper;
import com.ruoyi.edge.application.service.ServiceManagementService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 服务管理
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class ServiceManagementServiceImpl implements ServiceManagementService {

    private final ServiceManagementMapper serviceManagementMapper;

    @Override
    public TableDataInfo<ServiceManagement> listPage(ServiceManagement serviceManagement, PageQuery pageQuery) {

        LambdaQueryWrapper<ServiceManagement> lqw = new LambdaQueryWrapper<>();
        Page<ServiceManagement> page = serviceManagementMapper.selectPage(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }

    @Override
    public R<ServiceManagement> get(String id) {
        ServiceManagement serviceManagement = serviceManagementMapper.selectById(id);
        return R.ok(serviceManagement);
    }

    @Override
    public R<String> add(ServiceManagement serviceManagement) {
        serviceManagementMapper.insert(serviceManagement);
        return R.ok("新增成功");
    }

    @Override
    public R<String> edit(ServiceManagement serviceManagement) {
        serviceManagementMapper.updateById(serviceManagement);
        return R.ok("修改成功");
    }

    @Override
    public R<String> remove(String id) {
        serviceManagementMapper.deleteById(id);
        return R.ok("删除成功");
    }
}
